home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 2000 July: Mac OS SDK / Dev.CD Jul 00 SDK2.toast / Development Kits / Cross Platform / QuickTime 4.1.2 Windows SDK / CIncludes / NumberFormatting.h < prev    next >
Encoding:
C/C++ Source or Header  |  2000-04-12  |  4.3 KB  |  192 lines  |  [TEXT/R*ch]

  1. /*
  2.      File:        NumberFormatting.h
  3.  
  4.      Contains:    Utilites for formatting numbers
  5.  
  6.      Version:    Technology:    
  7.                  Release:    QuickTime 4.1
  8.  
  9.      Copyright:    (c) 1996-1999 by Apple Computer, Inc., all rights reserved.
  10.  
  11.      Bugs?:        For bug reports, consult the following page on
  12.                  the World Wide Web:
  13.  
  14.                      http://developer.apple.com/bugreporter/
  15.  
  16. */
  17. #ifndef __NUMBERFORMATTING__
  18. #define __NUMBERFORMATTING__
  19.  
  20. #ifndef __CONDITIONALMACROS__
  21.     #include <ConditionalMacros.h>
  22. #endif
  23.  
  24. #ifndef __MACTYPES__
  25.     #include <MacTypes.h>
  26. #endif
  27.  
  28. #ifndef __INTLRESOURCES__
  29.     #include <IntlResources.h>
  30. #endif
  31.  
  32.  
  33.  
  34.  
  35.  
  36. #if PRAGMA_ONCE
  37. #pragma once
  38. #endif
  39.  
  40. #ifdef __cplusplus
  41. extern "C" {
  42. #endif
  43.  
  44. #if PRAGMA_IMPORT
  45. #pragma import on
  46. #endif
  47.  
  48. #if PRAGMA_STRUCT_ALIGN
  49.     #pragma options align=mac68k
  50. #elif PRAGMA_STRUCT_PACKPUSH
  51.     #pragma pack(push, 2)
  52. #elif PRAGMA_STRUCT_PACK
  53.     #pragma pack(2)
  54. #endif
  55.  
  56. /*
  57.  
  58.     Here are the current System 7 routine names and the translations to the older forms.
  59.     Please use the newer forms in all new code and migrate the older names out of existing
  60.     code as maintainance permits.
  61.     
  62.     New Name                    Old Name(s)
  63.     
  64.     ExtendedToString            FormatX2Str
  65.     FormatRecToString            Format2Str
  66.     NumToString                
  67.     StringToExtended            FormatStr2X
  68.     StringToFormatRec            Str2Format
  69.     StringToNum                
  70.  
  71. */
  72.  
  73. struct NumFormatString {
  74.     UInt8                             fLength;
  75.     UInt8                             fVersion;
  76.     char                             data[254];                    /* private data */
  77. };
  78. typedef struct NumFormatString            NumFormatString;
  79. typedef NumFormatString                 NumFormatStringRec;
  80.  
  81. typedef short                             FormatStatus;
  82. enum {
  83.     fVNumber                    = 0                                /* first version of NumFormatString */
  84. };
  85.  
  86. typedef SInt8                             FormatClass;
  87. enum {
  88.     fPositive                    = 0,
  89.     fNegative                    = 1,
  90.     fZero                        = 2
  91. };
  92.  
  93. typedef SInt8                             FormatResultType;
  94. enum {
  95.     fFormatOK                    = 0,
  96.     fBestGuess                    = 1,
  97.     fOutOfSynch                    = 2,
  98.     fSpuriousChars                = 3,
  99.     fMissingDelimiter            = 4,
  100.     fExtraDecimal                = 5,
  101.     fMissingLiteral                = 6,
  102.     fExtraExp                    = 7,
  103.     fFormatOverflow                = 8,
  104.     fFormStrIsNAN                = 9,
  105.     fBadPartsTable                = 10,
  106.     fExtraPercent                = 11,
  107.     fExtraSeparator                = 12,
  108.     fEmptyFormatString            = 13
  109. };
  110.  
  111.  
  112. struct FVector {
  113.     short                             start;
  114.     short                             length;
  115. };
  116. typedef struct FVector                    FVector;
  117. /* index by [fPositive..fZero] */
  118.  
  119. typedef FVector                         TripleInt[3];
  120. EXTERN_API_C( void )
  121. stringtonum                        (const char *            theString,
  122.                                  long *                    theNum);
  123.  
  124. EXTERN_API_C( void )
  125. numtostring                        (long                     theNum,
  126.                                  char *                    theString);
  127.  
  128. EXTERN_API( void )
  129. StringToNum                        (ConstStr255Param         theString,
  130.                                  long *                    theNum);
  131.  
  132. EXTERN_API( void )
  133. NumToString                        (long                     theNum,
  134.                                  Str255                 theString);
  135.  
  136. EXTERN_API( FormatStatus )
  137. ExtendedToString                (const extended80 *        x,
  138.                                  const NumFormatString * myCanonical,
  139.                                  const NumberParts *    partsTable,
  140.                                  Str255                 outString)                            FOURWORDINLINE(0x2F3C, 0x8210, 0xFFE8, 0xA8B5);
  141.  
  142. EXTERN_API( FormatStatus )
  143. StringToExtended                (ConstStr255Param         source,
  144.                                  const NumFormatString * myCanonical,
  145.                                  const NumberParts *    partsTable,
  146.                                  extended80 *            x)                                    FOURWORDINLINE(0x2F3C, 0x8210, 0xFFE6, 0xA8B5);
  147.  
  148. EXTERN_API( FormatStatus )
  149. StringToFormatRec                (ConstStr255Param         inString,
  150.                                  const NumberParts *    partsTable,
  151.                                  NumFormatString *        outString)                            FOURWORDINLINE(0x2F3C, 0x820C, 0xFFEC, 0xA8B5);
  152.  
  153. EXTERN_API( FormatStatus )
  154. FormatRecToString                (const NumFormatString * myCanonical,
  155.                                  const NumberParts *    partsTable,
  156.                                  Str255                 outString,
  157.                                  TripleInt                 positions)                            FOURWORDINLINE(0x2F3C, 0x8210, 0xFFEA, 0xA8B5);
  158.  
  159.  
  160. #if OLDROUTINENAMES
  161. #define FormatX2Str(x, myCanonical, partsTable, outString)  \
  162.          ExtendedToString( x, myCanonical, partsTable, outString)
  163. #define FormatStr2X(source, myCanonical, partsTable, x)  \
  164.          StringToExtended( source, myCanonical, partsTable, x)
  165. #define Str2Format(inString, partsTable, outString)  \
  166.          StringToFormatRec(inString, partsTable, outString)
  167. #define Format2Str(myCanonical, partsTable, outString, positions)  \
  168.          FormatRecToString(myCanonical, partsTable, outString, positions)
  169. #endif  /* OLDROUTINENAMES */
  170.  
  171.  
  172. #if PRAGMA_STRUCT_ALIGN
  173.     #pragma options align=reset
  174. #elif PRAGMA_STRUCT_PACKPUSH
  175.     #pragma pack(pop)
  176. #elif PRAGMA_STRUCT_PACK
  177.     #pragma pack()
  178. #endif
  179.  
  180. #ifdef PRAGMA_IMPORT_OFF
  181. #pragma import off
  182. #elif PRAGMA_IMPORT
  183. #pragma import reset
  184. #endif
  185.  
  186. #ifdef __cplusplus
  187. }
  188. #endif
  189.  
  190. #endif /* __NUMBERFORMATTING__ */
  191.  
  192.